Repository navigation
Conversation
Signed-off-by: fernvenue <git@fernvenue.com>
gabriel-samfira
requested changes
Nov 24, 2026
gabriel-samfira
left a comment
Member
There was a problem hiding this comment.
Just a few suggestions. We should probably do this for GitHub and Windows as well. Because the same race can happen there as well.
| sed -i 's/$/\.service/' "$RUN_HOME"/.service | ||
| SVC_NAME=$(cat "$RUN_HOME"/.service) | ||
|
|
||
| AGENT_ID="" |
Member
There was a problem hiding this comment.
Let's try something like this:
function sendSystemInfo() {
set +e
AGENT_ID=$(grep '"id"' "$RUN_HOME"/.runner | tr -d -c 0-9)
if [ $? -ne 0 ];then
fail "failed to get agent ID"
fi
set -e
systemInfo $AGENT_ID
success "runner successfully installed" $AGENT_ID
}| fi | ||
|
|
||
| sudo systemctl daemon-reload || fail "failed to reload systemd" | ||
|
|
Member
There was a problem hiding this comment.
We can then remove this bit
| sendStatus "starting service" | ||
| if [ "$AGENT_MODE" == "true" ]; then | ||
| sendStatus "Enabling garm-agent service" | ||
| sudo systemctl enable --now garm-agent |
Member
There was a problem hiding this comment.
We can remove this line and replace it with:
SVC_NAME="garm-agent"| fail "failed to get agent ID" | ||
| fi | ||
| set -e | ||
| if [ "$AGENT_MODE" == "true" ]; then |
Member
There was a problem hiding this comment.
and here we can then call:
sendSystemInfo
sudo systemctl enable --now $SVC_NAME|
|
||
| systemInfo $AGENT_ID | ||
| success "runner successfully installed" $AGENT_ID | ||
| sudo systemctl enable --now $SVC_NAME |
Member
There was a problem hiding this comment.
and of course, we can remove this
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #971.
In non-agent mode the install template starts the runner service (
systemctl enable --now) and only afterwards reads the agent ID and reportsidle. An ephemeral runner can pick up an already-queued job in between: the forge reports the jobin_progress, garm marks the runneractive, and the finalidlestatus callback is then rejected with 401 by the instance middleware, because the runner is no longerinstalling/pending. garm never records the agent ID.This moves the agent ID lookup, the system-info report and the
idlestatus report beforesystemctl enable --now, as suggested on #971. Agent mode is unchanged.Tested on a self-hosted Gitea (latest) with an external ECS provider, non-agent mode, by applying the same reordering to a copy of this template: the final status callback returns 200 instead of 401, the runner goes
pending->installing->activewith its agent ID recorded, and the job completes. Agent mode was not tested.Trade-off:
idleis now reported before the service is started. Ifsystemctl enable --nowfails afterwards, garm cannot be told, because the runner status transitions do not allowidle->failed.Only the Gitea Linux template is changed. The GitHub Linux template appears to share the ordering (
svc.sh startcomes before reading.runnerand the idle report), but I have not changed or tested it.Not addressed here:
job never got assigned to a runner, ignoringis still logged fromhandleCompletedJobwhen the completed event carries an empty runner name. That is separate from the 401.